package com.huawei.gamebox.plugin.gameservice.view;

import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.text.TextUtils;
import com.huawei.appgallery.foundation.account.bean.UserSession;
import com.huawei.appgallery.foundation.ui.framework.activity.AbstractBaseActivity;
import com.huawei.cloudservice.CloudAccountManager;
import com.huawei.gamebox.plugin.gameservice.bean.GameInfo;
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant;
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant.KeyAndValue;
import com.huawei.hwid.core.helper.handler.ErrorStatus;
import com.huawei.secure.android.common.intent.SafeBroadcastReceiver;
import com.huawei.secure.android.common.intent.SafeIntent;
import o.ayw;
import o.ayy;
import o.ccm;
import o.AccountBussinessListener;
import o.ccp;
import o.ccs;
import o.dgh;
import o.Logger;
import o.ContentManager;
import o.eod;
import o.eoj;
import o.ezl;
import o.ezm;
import o.ezu;
import o.fae;
import o.fam;
import o.ll;

public class GameLoginActivity extends Activity {
    private ll ˊ;
    private final BroadcastReceiver ॱ = new SafeBroadcastReceiver(this) {
        final /* synthetic */ GameLoginActivity ˊ;

        {
            this.ˊ = r1;
        }

        public void onReceiveMsg(Context context, Intent intent) {
            if ("com.huawei.systemmanager.action.CHANGE_HOME_COUNTRY".equals(intent.getAction())) {
                this.ˊ.finish();
            }
        }
    };

    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        ayy.ˋ().ˎ(getWindow());
        requestWindowFeature(1);
        ayw.ॱ(this);
        ʻ();
        SafeIntent safeIntent = new SafeIntent(getIntent());
        CharSequence action = safeIntent.getAction();
        if (Logger.ˎ()) {
            Logger.ˏ("GameLoginActivity", "GameLoginActivity action:" + action);
        }
        if (TextUtils.isEmpty(action) || !"com.huawei.gamebox.plugin.gameservice.GameLoginActivity.action.initHwid".equals(action)) {
            finish();
            return;
        }
        String stringExtra = safeIntent.getStringExtra("loginParam");
        if (Logger.ˎ()) {
            Logger.ˏ("GameLoginActivity", "GameLoginActivity param:" + stringExtra);
        }
        int i = -1;
        switch (stringExtra.hashCode()) {
            case 3005864:
                if (stringExtra.equals("auth")) {
                    i = 2;
                    break;
                }
                break;
            case 3035517:
                if (stringExtra.equals("buoy")) {
                    i = 3;
                    break;
                }
                break;
            case 3237136:
                if (stringExtra.equals("init")) {
                    i = 0;
                    break;
                }
                break;
            case 109757538:
                if (stringExtra.equals("start")) {
                    i = 1;
                    break;
                }
                break;
        }
        switch (i) {
            case 0:
                ˎ();
                return;
            case 1:
                ˋ();
                return;
            case 2:
                ˊ();
                return;
            case 3:
                ॱ();
                return;
            default:
                finish();
                return;
        }
    }

    private void ˊ() {
        ezl.ˎ().ˋ(this, true, true, new ezm(this) {
            final /* synthetic */ GameLoginActivity ॱ;

            {
                this.ॱ = r1;
            }

            public void ˊ(ccm o_ccm) {
                if (o_ccm != null) {
                    ezu.ˊ().ˊ(o_ccm);
                }
                this.ॱ.finish();
            }

            public void ˏ(int i, String str) {
                Logger.e("GameLoginActivity", "auth login onError, errorCode:" + i + ", errorDesc:" + str);
                if (i == 1) {
                    ezu.ˊ().ॱ();
                } else {
                    ezu.ˊ().ˏ(ezu.ˊ().ॱ(i));
                }
                this.ॱ.finish();
            }
        });
    }

    private void ˋ() {
        if (Logger.ˎ()) {
            Logger.ˏ("GameLoginActivity", "startQuickLogin.");
        }
        ezm anonymousClass5 = new ezm(this) {
            final /* synthetic */ GameLoginActivity ˏ;

            {
                this.ˏ = r1;
            }

            public void ˊ(ccm o_ccm) {
                if (o_ccm != null) {
                    ezu.ˊ().ॱ(o_ccm.ˊ());
                }
                this.ˏ.finish();
            }

            public void ˏ(int i, String str) {
                Logger.e("GameLoginActivity", "startQuickLogin failed, errorCode:" + i + ", errorDesc:" + str);
                if (i == 1) {
                    ezu.ˊ().ॱ();
                    this.ˏ.finish();
                } else if (i == 4) {
                    this.ˏ.ˏ();
                } else {
                    ezu.ˊ().ˏ(ezu.ˊ().ॱ(i));
                    this.ˏ.finish();
                }
            }
        };
        anonymousClass5.ॱ(true);
        ezl.ˎ().ˋ(this, false, false, anonymousClass5);
    }

    private void ˏ() {
        if (Logger.ˎ()) {
            Logger.ˏ("GameLoginActivity", "startLogin.");
        }
        ezl.ˎ().ˋ(this, false, false, new ezm(this) {
            final /* synthetic */ GameLoginActivity ˎ;

            {
                this.ˎ = r1;
            }

            public void ˊ(ccm o_ccm) {
                if (o_ccm != null) {
                    ezu.ˊ().ॱ(o_ccm.ˊ());
                }
                this.ˎ.finish();
            }

            public void ˏ(int i, String str) {
                Logger.e("GameLoginActivity", "startLogin failed, errorCode:" + i + ", errorDesc:" + str);
                if (i == 1) {
                    ezu.ˊ().ॱ();
                    this.ˎ.finish();
                    return;
                }
                ezu.ˊ().ˏ(ezu.ˊ().ॱ(i));
                this.ˎ.finish();
            }
        });
    }

    private void ॱ() {
        if (Logger.ˎ()) {
            Logger.ˏ("GameLoginActivity", "startBuoyLogin");
        }
        eoj.ˋ().ˎ("GameLoginActivity", new AccountBussinessListener(this) {
            final /* synthetic */ GameLoginActivity ˏ;

            {
                this.ˏ = r1;
            }

            public void onAccountBusinessResult(ccp o_ccp) {
                if (o_ccp.ˎ == 102) {
                    this.ˏ.ˋ("1");
                } else {
                    this.ˏ.ˋ("0");
                }
                this.ˏ.finish();
                eoj.ˋ().ˊ("GameLoginActivity");
            }
        });
        eod.ॱ(this);
    }

    private void ˋ(String str) {
        fae ˏ = fam.ॱ().ˏ();
        if (ˏ != null) {
            GameInfo gameInfo = ˏ.getGameInfo();
            if (gameInfo != null) {
                dgh.ॱ(this, "15150607", new StringBuffer().append(KeyAndValue.NUMBER_01).append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR).append(UserSession.getInstance().getUserId()).append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR).append(gameInfo.getPackageName()).append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR).append(gameInfo.getAppId()).append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR).append(gameInfo.getSdkVersionCode()).append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR).append(str).toString());
            }
        }
    }

    private void ˎ() {
        if (Logger.ˎ()) {
            Logger.ˏ("GameLoginActivity", "GameLoginActivity initHwid start.");
        }
        CloudAccountManager.initial(this, new Bundle(), new ccs(this) {
            final /* synthetic */ GameLoginActivity ˊ;

            {
                this.ˊ = r1;
            }

            public void onError(ErrorStatus errorStatus) {
                if (Logger.ˎ()) {
                    Logger.ˏ("GameLoginActivity", "initial onError ErrorCode:" + errorStatus.getErrorCode() + ", ErrorReason:" + errorStatus.getErrorReason());
                }
                super.onError(errorStatus);
                ezu.ˊ().ˏ(ezu.ˊ().ॱ(errorStatus.getErrorCode()));
                this.ˊ.finish();
            }

            public void onFinish(Bundle bundle) {
                ezu.ˊ().ॱ();
                this.ˊ.finish();
            }

            public String ˋ() {
                return "initial";
            }
        });
    }

    private void ʻ() {
        this.ˊ = ll.ˏ(ContentManager.getInstant().getContext());
        if (this.ˊ != null) {
            IntentFilter intentFilter = new IntentFilter();
            intentFilter.addAction("com.huawei.systemmanager.action.CHANGE_HOME_COUNTRY");
            this.ˊ.ˏ(this.ॱ, intentFilter);
        }
    }

    protected void onDestroy() {
        if (Logger.ˎ()) {
            Logger.ˏ("GameLoginActivity", "onDestroy");
        }
        if (this.ˊ != null) {
            this.ˊ.ˋ(this.ॱ);
        }
        super.onDestroy();
    }

    protected void onResume() {
        super.onResume();
        AbstractBaseActivity.ˎ(this);
    }

    protected void onPause() {
        super.onPause();
        AbstractBaseActivity.ˎ(null);
    }

    public void finish() {
        if (Logger.ˎ()) {
            Logger.ˏ("GameLoginActivity", "finish");
        }
        super.finish();
    }
}
